package com.design.pattern.behaviour.observer;

import lombok.Data;

/**
 * @Author hanyuanlai
 * @Date 2022/8/22
 */
@Data
public class ConcreteObserver extends Observer{
    private String name;
    private String observerState;
    private ConcreteSubject concreteSubject;

    public ConcreteObserver(String name, ConcreteSubject concreteSubject) {
        this.name = name;
        this.concreteSubject = concreteSubject;
    }

    @Override
    void update() {
        observerState = concreteSubject.getState();
        System.out.println("观察者:" + name + "的新状态:" + observerState);
    }
}
